import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { fileURLToPath } from "url";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
        modifyVars: {
          // 可以在这里自定义 antd 主题变量
          "@primary-color": "#1890ff",
        },
      },
    },
  },
  server: {
    port: 3000,
    open: true,
    proxy: {
      '/api_apifox_proxy': {
        target: "http://127.0.0.1:4523/m2/6988617-6706178-default",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api_apifox_proxy/, ""),
      },
      "/api_example_proxy": {
        target: "http://localhost:8080",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api_example_proxy/, ""),
      },
      "/api_proxy": {
        target: "http://localhost:8080",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api_proxy/, ""),
      },
    },
  },
  build: {
    outDir: "dist",
    sourcemap: true,
  },
});
